package com.qfjy.config.example3;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class WeatherConfig {
    /**
     * 1、定义交换机（Fanout)
     * 2、分别定义队列
     * 3、交换机和队列进行绑定
     */
    //1、定义交换机（Fanout)
    @Bean
    public FanoutExchange fanoutExchange(){

        return new FanoutExchange("fanoutWeatherExchange");
    }
    //2、分别定义队列
    @Bean
    public Queue taobaoQueue(){

        return new Queue("taobaoQueue");
    }
    @Bean
    public Queue jdQueue(){

        return new Queue("jdQueue");
    }
    /**
     * 3、队列和交换机进行绑定
     */
    @Bean
    public Binding bindFanoutTaobaoQueue(Queue taobaoQueue,FanoutExchange fanoutExchange){
        return BindingBuilder.bind(taobaoQueue).to(fanoutExchange);
    }

    @Bean
    public Binding bindFanoutJdQueue(FanoutExchange fanoutExchange){

        return BindingBuilder.bind(jdQueue()).to(fanoutExchange);
    }
}
